﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SDT.Model;
using SDT.Lib.Common;
using System.Text;
using SDT.Lib.Mail;
using SDT.Site.Properties;
using SDT.Site.Models;
namespace SDT.Site.Areas.User.Controllers
{
    public class AjaxDataController : Controller
    {
        SDTDataContext eDataContext = new SDTDataContext();
        public JsonResult SearchTag()
        {
            try
            {
                eDataContext.DeferredLoadingEnabled = false;
                var term = Request["keyword"].ToString();
                var keywords = eDataContext.Tags
                    .Where(e => e.Keyword.IndexOf(term) > -1)
                    .Take(10)
                    .ToList();
                return Json(keywords, JsonRequestBehavior.AllowGet);
            }
            catch
            {
                return Json("", JsonRequestBehavior.AllowGet);
            }
        }
    }
}
